//
//  CellForHotNews.m
//  MY Project For Sport
//
//  Created by dllo on 16/1/24.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellForHotNews.h"
#import "ModelForHotNews.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import <DKNightVersion.h>
#import "UIColor+Wonderful.h"
#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667


@interface CellForHotNews ()
@property (nonatomic, retain)UIView *view;
@property (nonatomic, retain) UILabel *content;
@property (nonatomic, retain) UIImageView *imageViewForHot;
@property (nonatomic, retain) UILabel *title;

@end


@implementation CellForHotNews
- (void)dealloc {
    [_imageViewForHot release];
    [_title release];
    [_content release];
    [_view release];
    [super dealloc];

}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.contentView.dk_backgroundColorPicker = DKColorWithColors([UIColor linenColor], [UIColor grayColor]);
        
        [self createSubview];
        
    }
    return self;

}

- (void)createSubview {

    self.view = [[UIView alloc] init];
    [self.contentView addSubview:self.view];
    [_view release];
    
    self.imageViewForHot = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageViewForHot];
    [_imageViewForHot release];
    
    
    self.title = [[UILabel alloc] init];
    [self.contentView addSubview:self.title];
    [_title release];
    
    self.content = [[UILabel alloc] init];
    [self.contentView addSubview:self.content];
    [_content release];
    
    
}
- (void)layoutSubviews {

    [super layoutSubviews];
    
    self.view.frame = CGRectMake(2, 5, self.contentView.frame.size.width - 4, self.contentView.frame.size.height - 10);
    //self.view.backgroundColor = [UIColor whiteColor];
    self.view.dk_backgroundColorPicker = DKColorWithRGB (0xffffff, 0x343434);

    self.imageViewForHot.frame = CGRectMake(2 * WEIGHTT, 5 * HEIGHTT, self.contentView.frame.size.width / 4, self.contentView.frame.size.height - 10 * HEIGHTT);
   // self.imageViewForHot.backgroundColor = [UIColor redColor];
    
    self.title.numberOfLines = 0;
    self.title.font = [UIFont systemFontOfSize:19];
    self.title.frame = CGRectMake(self.contentView.frame.size.width / 4 + 10 * WEIGHTT, 5 * HEIGHTT, self.contentView.frame.size.width - self.contentView.frame.size.width / 4 - 15 * WEIGHTT , (self.contentView.frame.size.height - 15 * HEIGHTT) / 3);
    
    self.title.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    self.content.font = [UIFont systemFontOfSize:15];
    self.content.textColor = [UIColor grayColor];
    self.content.numberOfLines = 0;
    self.content.frame = CGRectMake(self.contentView.frame.size.width / 4 + 10 * WEIGHTT, 10 * HEIGHTT+ (self.contentView.frame.size.height - 15) / 3, self.contentView.frame.size.width - self.contentView.frame.size.width / 4 - 15 * WEIGHTT , (self.contentView.frame.size.height - 15 * HEIGHTT) / 3 * 2);
    
}

-(void)passModelForHotNews:(ModelForHotNews *)model {

    self.title.text = model.jktitle;
    self.content.text = model.jksummary;
    [self.imageViewForHot sd_setImageWithURL:[NSURL URLWithString:model.image]];
    

}


- (void)awakeFromNib {
    // Initialization code
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
